'use strict';
/* Controller for adding a new entry*/

blogApp.controller('addCtrl',['$scope', '$http','$state',
    function($scope, $http,$state) {

        $scope.submit = function() {

            var entry = {};

            entry.title = this.title;
            entry.body = this.body;
            console.log("Submitting");

            var data = angular.toJson(entry);
            $http({
                    url: 'entries/addEntry',
                    method: "POST",
                    data: data,
                    headers: {'Content-Type': 'application/json'}
            }).success(function() {
                    $state.go('listAdmin', null, {reload:true});
                });
        };
    }
]);